const sendMessageId = document.getElementById("sendmessageid");

if (sendMessageId) {
    sendMessageId.onclick = function () {
        chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
            // 获取下拉框元素
            var selectElement = document.getElementById("speed");

            // 获取当前选中的值
            var selectedValue = selectElement.value;
            chrome.tabs.sendMessage(
                tabs[0].id,
                {
                    speed: selectedValue,
                },
                function (response) {
                    if (chrome.runtime.lastError) {
                        // 发送消息时出现了错误
                        alert('Error in sending message: ' + chrome.runtime.lastError.message);
                        // 进行相应的错误处理逻辑
                    } else {
                        // 成功发送消息并收到响应
                        window.close();
                    }
                }
            );
        });
    };
}